package com.example.demo.FactoryPattern;

/**
 * @author gyq
 * @description
 * @datetime 2019/2/23 20:19
 */
public class Test {
    public static void main(String[] args) {
        HairFactory hairFactory = new HairFactory();
        HairInterface hairInterface = hairFactory.getHair("Left");
        draw(hairInterface);
        hairInterface = hairFactory.getHair("Right");
        draw(hairInterface);
        hairInterface = hairFactory.getHair("lll");
        draw(hairInterface);

        PersonFactory factory = new HNFactory();
        Boy boy =  factory.getBoy();
        boy.drawMan();
    }

    public static void draw(HairInterface hairInterface) {
        if (null != hairInterface) {
            hairInterface.draw();
        } else {
            System.out.println("发型不存在");
        }
    }
}
